home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / notebook / libs < prev    next >
Text File  |  1989-06-27  |  6KB  |  318 lines

  1. .TL
  2. A Tour Through the C News Libraries and Include Files
  3. .AU
  4. Geoff Collyer
  5. .AI
  6. Department of Statistics
  7. University of Toronto
  8. .SH
  9. libc and friends
  10. .LP
  11. .I libc
  12. contains routines that are sufficiently useful
  13. and general that they could profitably be added to
  14. one's C library.
  15. Indeed,
  16. on some systems they are in the C library.
  17. Notable inventions include
  18. .I fgetmfs
  19. which safely reads arbitrarily-long input lines;
  20. it has an
  21. .B fgetmfs.h
  22. over in the header directories.
  23. .I ldiv
  24. is the ANSI one,
  25. if you need it.
  26. .I memlist
  27. is a
  28. package to ease keeping track of a lot of allocated memory.
  29. .I stdfdopen
  30. is invoked by setuid programs
  31. to ensure that the standard file descriptors are indeed open,
  32. opening
  33. .B /dev/null
  34. on each closed standard descriptor.
  35. .\".B libc/memcpy.fast
  36. .\"contains some alternate
  37. .\"implementations of
  38. .\".I memcpy (3)
  39. .\"which may be faster than the ones in your local C library.
  40. .LP
  41. .B libstdio
  42. contains new (faster) guts for
  43. the original
  44. .UX
  45. .I stdio
  46. library;
  47. if they compile on your V7,
  48. 4BSD
  49. or System III
  50. system,
  51. you may want to use them instead of the default versions
  52. in your C library.
  53. On System V,
  54. these routines are only slightly faster than the versions in the C library.
  55. .LP
  56. .B libfake
  57. contains things that probably should be in your C library,
  58. but might not be, and a couple of fake routines for system calls
  59. you might not have.
  60. .SH
  61. libcnews
  62. .LP
  63. .B libcnews
  64. contains functions of general use to news software,
  65. but not the world at large.
  66. .I complain
  67. is like
  68. .I warning ,
  69. but never prints the symbolic value of
  70. .I errno .
  71. .PP
  72. There is a locking package,
  73. containing
  74. .I lockdebug ,
  75. .I newslock ,
  76. .I newsunlock ,
  77. .I errunlock ,
  78. and
  79. .I nemalloc .
  80. .I lockdebug
  81. enables or disables lock debugging.
  82. .I newslock
  83. attempts to lock
  84. the news transport layer
  85. against
  86. read-then-write access to the
  87. .B active
  88. file,
  89. writing to the
  90. .B history *,
  91. .B log ,
  92. .B errlog ,
  93. and batch files.
  94. It returns only when it has the lock;
  95. in the meantime it sleeps and retries until it gets the lock.
  96. There is no timeout;
  97. this is a feature.
  98. .I newsunlock
  99. removes the above-mentioned lock
  100. if this process locked the news system.
  101. .I errunlock
  102. is like
  103. .I error
  104. except that it
  105. unlocks the news system
  106. (via
  107. .I newsunlock)
  108. before exiting;
  109. it is should always be called instead of
  110. .I exit (3)
  111. or
  112. .I exit (2)
  113. if there is any chance that this process has locked the news system.
  114. .I nemalloc
  115. is like
  116. .I emalloc
  117. but it calls
  118. .I errunlock
  119. if it can't allocate memory.
  120. .PP
  121. .I ltoza
  122. converts a
  123. .B "long int"
  124. to a string of a given width,
  125. containing the decimal representation,
  126. zero-padding as needed on the left.
  127. .I ltozan
  128. is like
  129. .I ltoza
  130. but omits the terminating NUL,
  131. so it can be used to overwrite a string without truncating it.
  132. .I ngmatch
  133. returns a truth-value
  134. resulting from comparing
  135. a list of newsgroup patterns
  136. and
  137. a list of newsgroups.
  138. One may substitute ``distribution'' for ``newsgroup''.
  139. .PP
  140. There is a package of pathname manipulators.
  141. .I artfile
  142. returns a name for its filename argument,
  143. assumed to be relative to
  144. .I $NEWSARTS ;
  145. .I fullartfile
  146. promises to return a fully-qualified path name.
  147. .I ctlfile
  148. returns a name for its filename argument,
  149. assumed to be relative to
  150. .I $NEWSCTL .
  151. .I binfile
  152. returns a name for its filename argument,
  153. assumed to be relative to
  154. .I $NEWSBIN .
  155. .I cd
  156. changes to its argument directory,
  157. check for errors,
  158. and notes the directory name,
  159. by making a private copy,
  160. for later optimisations.
  161. .I newsumask
  162. returns the value of
  163. .I $NEWSUMASK .
  164. .I newspath
  165. returns the value of
  166. .I $NEWSPATH .
  167. .I newsmaster
  168. returns the value of
  169. .I $NEWSMASTER .
  170. All these functions
  171. supply default values for the
  172. .I NEWS *
  173. variables if none are found in the environment.
  174. If values are found in the environment,
  175. they are used,
  176. and a function named
  177. .I unprivileged
  178. is called.
  179. .PP
  180. .I readline
  181. is like
  182. .I fgets ,
  183. but executes
  184. .I newslock
  185. upon encountering EOF
  186. and retries the read.
  187. This is used when reading growing files
  188. such as
  189. .B history
  190. or
  191. batch files.
  192. .I strlower
  193. down-cases an entire string,
  194. in place.
  195. .I strsave
  196. is like
  197. .I strdup
  198. but it calls
  199. .I nemalloc
  200. rather than
  201. .I emalloc .
  202. .I str3save
  203. takes three strings,
  204. allocates space for their concatenation
  205. via
  206. .I nemalloc ,
  207. including terminating NUL,
  208. and concatenates them onto it.
  209. A
  210. .I NULL
  211. argument will be replaced by an empty string.
  212. .I timestamp
  213. writes a timestamp on a given stream,
  214. and returns the current time via an argument
  215. for later use.
  216. .SH
  217. Unix-variant-specific libraries
  218. .LP
  219. There are several libraries that provide functions
  220. for talking to specific Unix variants.
  221. These are basically functions that change from one variant to another.
  222. .B libfake
  223. (see above) contains things which simply might not be there in a
  224. particular system.
  225. .LP
  226. These libraries all provide the same virtual interface to
  227. operating-system-dependent services:
  228. .I fclsexec ,
  229. .I fopenexcl ,
  230. .I getcwd (3),
  231. and
  232. .I gethostname (3).
  233. Implementations for vanilla implementations of these
  234. .UX
  235. variants are provided:
  236. Seventh Edition,
  237. including 4.1BSD
  238. (\c
  239. .B libv7 );
  240. Eighth
  241. and Ninth Editions
  242. (\c
  243. .B libv8 );
  244. 4.2BSD and later
  245. (\c
  246. .B libbsd42 );
  247. System III and System V
  248. (\c
  249. .B libusg ).
  250. .I fclsexec
  251. sets the close-on-exec flag
  252. for a given
  253. .I stdio
  254. stream.
  255. .I fopenexcl
  256. performs an ``exclusive create'' open:
  257. the open fails if the file already exists.
  258. .SH
  259. Address-space-size-specific libraries
  260. .LP
  261. These libraries provide alternate versions of the
  262. .B active
  263. and
  264. .B sys
  265. file code:
  266. .B libsmall
  267. should work on any machine,
  268. but is suboptimally fast;
  269. .B libbig
  270. has worked even on PDP-11s,
  271. and is quite fast,
  272. but consumes memory without apology.
  273. .SH
  274. Include files
  275. .LP
  276. .B libh
  277. contains include files
  278. unique to C news.
  279. .B news.h
  280. defines a few limits,
  281. some file names,
  282. some types
  283. (\c
  284. .B boolean
  285. and
  286. .B statust ),
  287. some characters,
  288. some status bits,
  289. some macros for speed,
  290. and
  291. declares functions in
  292. .B libcnews
  293. or miscellaneous functions in
  294. .I relaynews
  295. (oops!).
  296. .B config.h
  297. declares the pathname functions in
  298. .B libcnews .
  299. .B fgetmfs.h
  300. declares symbolic values and macros for using
  301. .B fgetmfs .
  302. .B libc.h
  303. is a start at a V9-like declaration of all of the C library.
  304. .B memlist.h
  305. defines the interface to
  306. .B memlist .
  307. .LP
  308. .B hfake
  309. contains a few include files that your system ought to have but might not.
  310. .B stdlib.h
  311. is a degenerate ANSI
  312. .B stdlib.h .
  313. .B string.h
  314. declares the string functions.
  315. .B timeb.h
  316. declares the structure used by
  317. .I ftime .
  318.